package com.yylany.service.impl;

import com.yylany.mapper.BlogMapper;
import com.yylany.page.PageData;
import com.yylany.page.PageParams;
import com.yylany.pojo.Blog;
import com.yylany.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * User  yyl
 * Description: house
 * Created by yaoyonglong on 2018/11/6 8:29
 */
@Service
public class BlogServiceImpl implements BlogService {

    @Autowired
    private BlogMapper blogMapper;

    @Override
    public PageData<Blog> queryBlog(Blog query, PageParams pageParams) {
        List<Blog> user = blogMapper.selectAll();
        Long count = Long.parseLong(user.size() + "");
        return PageData.buildPage(user, count, pageParams.getPageSize(), pageParams.getPageNum());
    }

    @Override
    public Blog queryOneBlog(int id) {
        return blogMapper.selectByPrimaryKey(id);
    }
}
